// reudx -> createStore  => @reduxjs/toolkit -> configureStore
import { configureStore } from "@reduxjs/toolkit";

// 引入 切片的 reducer
import app from "./modules/app";
import film from "./modules/film";
import book from "./modules/book";

// 调用 configureStore 创建 store
const store = configureStore({
  // reducer 配置，需要接受一个 rootReducer
  reducer: {
    app,
    film,
    book,
  },
});

// 从 store 本身推断出 `RootState` 和 `AppDispatch` 类型
export type RootState = ReturnType<typeof store.getState>;
// 推断出类型: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;

export default store;
